package com.sskj.one;

import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.one.bean.MusicBean;
import com.sskj.one.bean.TanChuangBean;
import com.sskj.one.bean.UpdataBean;
import com.sskj.one.http.HttpConfig;
import com.sskj.one.presenter.BasePresenter;

public class MainPresneter extends BasePresenter<MainActivity> {

    public void getMusic() {
        httpService.getMusic()
                .tag(this)
                .execute(new JsonCallBack<HttpData<MusicBean>>() {
                    @Override
                    public void onHTTPSuccess(HttpData<MusicBean> data) {
                        mView.getMusicOK(data.getData());
                    }
                });
    }

    public void checkVersion(String versionCode) {
        httpService.checkVersion(versionCode)
                .tag(this)
                .execute(new JsonCallBack<HttpData<UpdataBean>>(false) {
                    @Override
                    public void onError(Response<HttpData<UpdataBean>> response) {
                        super.onError(response);
                        getGonggao();
                    }

                    @Override
                    public void onHTTPSuccess(HttpData<UpdataBean> data) {
                        mView.checkVersionOK(data.getData());
                    }
                });
    }

    public void getGonggao() {
        httpService.getGonggao()
                .tag(this)
                .execute(new JsonCallBack<HttpData<TanChuangBean>>() {
                    @Override
                    public void onHTTPSuccess(HttpData<TanChuangBean> data) {
                        mView.getGongGaoOK(data.getData());
                    }
                });
    }


}
